﻿<%@ Page Title="Organization List - Services Directory" Language="C#" AutoEventWireup="true" CodeBehind="HOrganisationList.aspx.cs"
    Inherits="AB.ServiceDirectory.Design.Org.HOrganizationList" MasterPageFile="~/Site.Master" %>

<asp:Content ID="head" runat="server" ContentPlaceHolderID="head">
<script type="text/javascript">
    function Confirm_Active() {
        return confirm('Do you want to make this Organisation active ?');
    }
</script>
</asp:Content>
<asp:Content runat="server" ID="ContentTitle" ContentPlaceHolderID="ContentTitle">
    <h2>Organization List</h2>
</asp:Content>
<asp:Content ID="Content" ContentPlaceHolderID="Content" runat="server">
    <div class="grid740 simplebox">
        <asp:UpdatePanel runat="server">
            <ContentTemplate>
                <div class="titleh">
                    <h3 class="sorting_range">
                        <asp:LinkButton ID="LinkButtonAll" runat="server" CssClass="hg-blue" CommandName="all"
                            OnCommand="FilterByLetters_Command">All</asp:LinkButton>
                        <asp:LinkButton ID="LinkButton09" runat="server" CommandName="09" OnCommand="FilterByLetters_Command">0-9</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonAE" runat="server" CommandName="ae" OnCommand="FilterByLetters_Command">A B C D E</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonFJ" runat="server" CommandName="fj" OnCommand="FilterByLetters_Command">F G H I J</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonKN" runat="server" CommandName="kn" OnCommand="FilterByLetters_Command">K L M N</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonOR" runat="server" CommandName="or" OnCommand="FilterByLetters_Command">O P Q R</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonSV" runat="server" CommandName="sv" OnCommand="FilterByLetters_Command">S T U V</asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonWZ" runat="server" CommandName="wz" CssClass="last"
                            OnCommand="FilterByLetters_Command"> W X Y Z</asp:LinkButton>
                        <span class="right">
                            <asp:HyperLink ID="LinkCreate" runat="server" CssClass="hg-blue" NavigateUrl="~/Organisation/OrganisationDetails.aspx">Create</asp:HyperLink>
                            <asp:CheckBox ID="CheckBoxInactive" runat="server" Text="Include In-active" AutoPostBack="True"
                                OnCheckedChanged="CheckBoxInactiveCheckedChanged" />
                        </span>
                    </h3>
                </div>
                <div class="clear"></div>

                <asp:GridView ID="GridViewOrg" CssClass="tablesorter" runat="server" AutoGenerateColumns="False"
                    AllowPaging="True" PageSize="15" AllowSorting="True" DataSourceID="ObjectDataSourceOrganization">
                    <Columns>
                        <asp:TemplateField HeaderText="Organization Name" SortExpression="OrganisationName">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButtonOrganizationName" CausesValidation="false" runat="server" CommandName='<%# Eval("OrganizationId") %>' CommandArgument='<%#Eval("IsActive") %>'
                                    OnClientClick='<%# !(bool)Eval("IsActive") ? "return Confirm_Active();" : string.Empty %>' OnCommand="LinkButtonDepartmentName_Command"><%# Eval("OrganizationName")%>
                                    </asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="133px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Head Office Address Line 1" SortExpression="HeadOfficeAddressLine1">
                            <ItemTemplate>
                                <%#Eval("Address.AddressLine") %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Postcode" SortExpression="PostCode">
                            <ItemTemplate>
                                <%#Eval("Address.PostCode") %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="120px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Contact" SortExpression="Contact">
                            <ItemTemplate>
                                <%#string.Format("{0} {1}",Eval("Contact.FirstName"),Eval("Contact.Surname")) %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="137px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Is Active?" SortExpression="IsActive">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%#(bool) Eval("IsActive") ? "Yes" :"No" %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="82px"/>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <blockquote>There are no items to show.</blockquote>
                    </EmptyDataTemplate>
                    <PagerStyle CssClass="pagination_table"></PagerStyle>
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:ObjectDataSource ID="ObjectDataSourceOrganization" runat="server" SelectMethod="GetOrganization"
            TypeName="AB.ServiceDirectory.BO.HOrganizationBO" OnSelecting="ObjectDataSourceOrganizationSelecting"
            EnablePaging="true" SelectCountMethod="GetOrganizationCount" StartRowIndexParameterName="startRowIndex"
            MaximumRowsParameterName="maxRows" SortParameterName="sortType">
            <SelectParameters>
                <asp:Parameter Name="filter" Type="Object" ConvertEmptyStringToNull="False" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>
